checkout: Add SELinux labeling for checkout, use in deploy
authorColin Walters <walters@verbum.org>
Fri, 14 Apr 2017 17:17:15 +0000 (13:17 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 25 Apr 2017 16:52:33 +0000 (16:52 +0000)
commite8efd1c8dcaad8fbd3b05c400972d237406263e7
treebe96281a1f0437d16af803e84a74245503af113f
parent654b0c4877d42b3b15a87114408722e843687ded
checkout: Add SELinux labeling for checkout, use in deploy

This is a variant of the efforts in https://github.com/ostreedev/ostree/pull/741
Working on `rpm-ostree livefs`, I realized though I needed to just
check out *new* files directly into the live `/etc` (and possibly
delete obsolete files).

The way the current `/etc` merge works is fundamentally different from
that.  So my plan currently is to probably do something like:

 - Compute diff
 - Check out each *new* file individually (as a copy)
 - Optionally delete obsolete files

Also, a few other things become more important - in the current deploy code, we
copy all of the files, then relabel them. But we shouldn't expose to *live*
systems the race conditions of doing that, plus we should only relabel files we
checked out.

By converting the deploy's /etc code to use this, we fix the same TODO item
there around atomically having the label set up as we create files. And further,
if we kill the `/var` relabeling which I think is unnecessary since Anaconda
does it, we could delete large chunks of code there.

In the implementation, there are two types of things: regular files, and
symlinks. For regular files, in the `O_TMPFILE` case, we have the ability to
do *everything* atomically (including SELinux labeling) before linking it into
place. So let's just use that. For symlinks, we use `setfscreatecon()`.

Closes: #797
Approved by: jlebon
src/libostree/ostree-repo-checkout.c
src/libostree/ostree-repo.h
src/libostree/ostree-sepolicy-private.h
src/libostree/ostree-sepolicy.c
src/libostree/ostree-sysroot-deploy.c
tests/libtest.sh